﻿@{
    ViewBag.Title = "Index";
    Layout = "/Views/Shared/Shared.cshtml";
    //var order = ViewBag.Order as List<Order>;
    var orderDetails = ViewBag.OrderDetails as List<OrderDetails>;
    var user = ViewBag.User as List<User>;
    var productPic = ViewBag.ProductPic as List<ProductPic>;
    var userAddress = ViewBag.UserAddress as List<UserAddress>;
}

@model IEnumerable<Order>;


<section>
    <div class="view-product">
        <div class="info-center">
            <div class="manage-head">
                <h6 class="padding-left manage-head-con">订单管理</h6>
            </div>
            <div class="layui-form">
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col width="150">
                        <col width="200">
                        <col>
                    </colgroup>
                    <thead>
                        <tr>
                            <th width="8%">商品总价</th>
                            <th width="10%">状态</th>
                            <th width="10%">收货方式</th>
                            @*<th width="13%">收货人信息</th>*@
                            <th width="15%">创建时间</th>
                            <th width="10%">产品</th>
                            <th width="8%">支付方式</th>
                            <th width="9%">用户编号</th>
                            <th width="17%">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr>
                                <td>@item.TotalMoney</td>
                                <td id="status">@item.Status</td>
                                <td>@item.ReceivingType</td>
                               @* <td>
                                @foreach (var address in userAddress.Where(x=>x.Id==int.Parse(@item.ReceivingAddress)))
                                    {
                                        @address.Name @address.Phone @address.Province @address.City @address.DisTrict @address.DetailedAddress
                                    }
                                </td>*@
                                <td>@item.CreateTime</td>
                                <td>
                                     @foreach (var pic in productPic.Where(x => x.ProductId == int.Parse(@item.Ext1)))
                                        {
                                            <a href="/products/prodetails/@pic.ProductId">
                                                <img src="@pic.PicAddress" alt="" width="100px" height="50px">
                                            </a>
                                        }
                                </td>
                                <td>@item.Paymethod</td>
                                <td>
                                    @foreach (var us in user.Where(x => x.Id == @item.UserId))
                                    {
                                        @us.NickName
                                    }
                                </td>
                                <td>
                                    <el-button style="padding:3px 5px;width:65px" typeof="text"><i class="el-icon-shopping-cart-full"></i> <el-link type="primary" plain href="/ZhiFu/edit/@item.Id">支付</el-link></el-button>
                                    <el-button style="padding:3px 5px;width:65px" typeof="text"><i class="el-icon-delete"></i><el-link type="danger" plain href="/DingDan/del/@item.Id">删除</el-link></el-button>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</section>
<script>
    var sta = document.getElementById("status").innerText;
    if (sta == "1") {
        document.getElementById("status").innerHTML = "未付款";
    } else if (sta == "2") {
        document.getElementById("status").innerHTML = "已付款";
    }
    else if (sta == "3") {
        document.getElementById("status").innerHTML = "未发货";
    } else if (sta == "4") {
        document.getElementById("status").innerHTML = "已发货";
    }
</script>
